<script setup>
import { computed } from 'vue'
defineEmits(['create', 'refresh', 'delete', 'download'])
const props = defineProps({
  layout: {
    type: String,
    default: 'create,refresh'
  }
})
const btns = computed(() => props.layout.split(','))
</script>
<template>
  <div class="flex items-center justify-between">
    <div>
      <el-button v-if="btns.includes('create')" type="primary" size="small" @click="$emit('create')">新增</el-button>
      <el-popconfirm v-if="btns.includes('delete')" title="是否要删除选中记录？" confirm-button-text="确认" cancel-button-text="取消"
        @confirm="$emit('delete')">
        <template #reference>
          <el-button type="danger" size="small">批量删除</el-button>
        </template>
      </el-popconfirm>
      <!-- 上架下架按钮 -->
      <slot></slot>
    </div>
    <div>
      <el-tooltip v-if="btns.includes('refresh')" content="刷新数据" effect="dark" placement="top">
        <el-button size="small" text @click="$emit('refresh')">
          <el-icon :size="15">
            <Refresh></Refresh>
          </el-icon>
        </el-button>
      </el-tooltip>
      <el-tooltip v-if="btns.includes('download')" content="导出数据" effect="dark" placement="top">
        <el-button size="small" text @click="$emit('download')">
          <el-icon :size="15">
            <Download></Download>

          </el-icon>
        </el-button>
      </el-tooltip>
    </div>

  </div>
</template>
